<?php

namespace App\Exports;

use App\Models\DispatchOrder as Order;
use App\Models\DispatchOrderList as OrderList;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromCollection;
use App\Exports\BaseExport;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;		// 引入 '列格式化'
use Maatwebsite\Excel\Concerns\ShouldAutoSize; //在工作表中，自动调整列宽
use Maatwebsite\Excel\Concerns\WithMultipleSheets;

class SortingExport implements WithMultipleSheets,ShouldAutoSize
{
    use Exportable;
    protected $year;
    public function __construct(int  $array)
    {
        $this->year =$array;
    }

    //注意返回的二维数组，数组中的每一个数组代表一行
    public function sheets() : array
    {
        $sheets = [];
        for ($month = 0; $month <= 2; $month++) {
            //不同的数据可以调用不同的方法
            $sheets[] = new SortingPerMonthSheet($this->year, $month);
        }
        return $sheets;
    }

}